<template>
    <div class="app-container dialog" v-if="form">
            <div class="title">业务系统基本信息</div>
            <div class="wrap1">
                <div><div>系统名称:</div>{{form.cloudUp.projectname}}</div>
                <div><div>云服务商:</div>{{form.cloudUp.supplierName}}</div>
                <div><div>上线时间:</div>{{form.cloudUp.onlinetime}}</div>
                <div><div>上云区域:</div>{{ translatecloudUpArea(form.cloudUp.cloudUpArea) }}</div>
                <div><div>业务部门:</div>{{form.cloudUp.officeName}}</div>
                <div><div>业主方联系人:</div>{{form.cloudUp.contactsNickName}}</div>
                <div><div>联系电话:</div>{{form.cloudUp.contactsinfo}}</div>
                <div><div>邮箱:</div>{{form.cloudUp.email}}</div>
                <div><div>承建单位:</div>{{form.cloudUp.constunit}}</div>
                <div><div>承建方联系人:</div>{{form.cloudUp.constcts}}</div>
                <div><div>联系电话:</div>{{form.cloudUp.constctsinfo}}</div>
                <div><div>邮籍:</div>{{form.cloudUp.constemail}}</div>
                <div style="width: 100%;"><div style="width: auto;">系统建设（运维）资金来源:</div>{{form.cloudUp.fundFrom}}</div>
                <div style="width: 100%;"><div  style="width: auto;">自行落实部门上云经费:</div>{{form.cloudUp.fundBySelf?'是':'否'}}</div>
                <div style="width: 100%;"><div>项目简介:</div>{{form.cloudUp.introduction}}</div>
                <div style="width: 100%;"><div>申请理由:</div>{{form.cloudUp.remarks}}</div>
            </div>
            <div class="title">申请资源</div>
            <div style="width: 100%;"><label style="margin-right: 10px;">服务商:</label>
              <span >{{form.cloudSupplier_label}}</span>
            </div>
            <div class="wrap">
                <div class="wrap_title">
                    <div>服务器</div>
                </div>
                <el-table v-if="form.hosts" :data="form.hosts"  style="width: 100%;margin-top: 13px;">
                        <el-table-column label="资源类型">
                            <template slot-scope="scope">
                                {{scope.row.flavorType==1?'云服务器':scope.row.flavorType==2?'高性能服务器':scope.row.serverCode?'数据库':'存储产品'}}
                            </template>
                        </el-table-column>
                        <el-table-column label="服务器名称 / 所属服务器">
                            <template slot-scope="scope">
                                <span v-if="scope.row.flavorType">{{scope.row.hostName}}</span>
                                <span v-else-if="scope.row.serverCode">{{scope.row.hostInstanceName||scope.row.host.instanceName}}</span>
                                <span v-else-if="!scope.row.hostInstanceNames.length"></span>
                                <div v-else style="margin-bottom: 6px;" v-for="(item,index) in scope.row.hostInstanceNames" :key="index">
                                    {{item}}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="资源详情">
                            <template slot-scope="scope">
                                <div
                                v-if="scope.row.flavorType"
                                placement="top-start"
                                width="300"
                                trigger="hover">
                                    <div style="margin-bottom: 6px;" v-if="scope.row.flavorType==2">
                                        <label>资源类型:</label>{{wlfwqLists(scope.row.cloudFlavorCode) || '高性能服务器'}}
                                    </div>
                                    <div style="margin-bottom: 6px;" v-if="scope.row.flavorType == 1">
                                    <label>规格：</label>
                                        <!-- {{scope.row.cloudFlavorCode_desc}} -->
                                        {{scope.row.cpuNumber}}vCPU； {{scope.row.memorySize}}G内存
                                    </div>
                                    <div style="margin-bottom: 6px;" v-if="scope.row.flavorType == 2">
                                        <label>规格：</label>
                                        {{scope.row.cloudFlavorCode_desc || cloudFlavorCodeDesc(scope.row.cloudFlavorCode)}}
                                        <!-- {{scope.row.cpuNumber}}vCPU； {{scope.row.memorySize}}G内存 -->
                                    </div>
                                    <div style="margin-bottom: 6px;" v-if="scope.row.flavorType==1 && scope.row.osDisk" >
                                        <label>系统盘：</label>{{scope.row.osDisk.diskServerName}}，{{scope.row.osDisk.dataDiskSize}}GB
                                    </div>
                                    <div style="margin-bottom: 6px;" v-if="scope.row.flavorType==1 || scope.row.flavorType==2">
                                        <label>操作系统：</label>{{scope.row.osName}}
                                    </div>
                                    <div style="margin-bottom: 6px;" v-if="scope.row.flavorType == 1"><label>
                                        数据盘(共<span style="color: #E83112;">{{scope.row.disks.length}}</span>块){{scope.row.disks.length?':':''}}</label>
                                    </div>
                                    <div style="margin:0 0 6px 16px;" v-if="scope.row.flavorType == 1" v-for="(item,index) in scope.row.disks" :key="index">
                                        <span>{{item.dataDiskType_label||item.diskServerName}}</span>，{{item.dataDiskSize}}GB
                                    </div>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="priceFlag"  width="600">
                            <template slot="header" slot-scope="scope">
                                <div style="text-align: center;">费用</div>
                                <div class="tab_wrap" >
                                    <div>名称</div>
                                    <div>单价</div>
                                    <div>用量</div>
                                    <div>总价（天）</div>
                                </div>
                            </template>
                            <template slot-scope="scope">
                                <div class="tab_wrap" v-for="(item,index) in scope.row.meterageList||[scope.row.meterage]" :key="index">
                                <div>{{item.resourceName}}</div>
                                <div>{{item.useCount}}{{item.useCountUnit}}</div>
                                <div> {{item.resourcePrice}}{{item.resourcePriceUnit}}</div>
                                <div> ¥{{item.resourcePriceTotalStr}}</div>
                                </div>
                            </template>
                    </el-table-column>
                    <el-table-column label="变更后">
                        <template slot-scope="scope" v-if="scope.row.changeTo">
                            <div v-if="!scope.row.changeTo.insStatus">未变更</div>
                            <div v-else-if="scope.row.changeTo.insStatus=='REMOVE'">已删除</div>
                            <div v-else>
                            <div
                                v-if="scope.row.changeTo"
                                placement="top-start"
                                width="300"
                                trigger="hover"
                            >
                                <div style="margin-bottom: 6px" v-if="scope.row.flavorType == 2">
                                        <label
                                            >
                                            资源类型：
                                            <template v-if="scope.row.flavorType == 2">
                                                {{
                                                    wlfwqLists(scope.row.changeTo?scope.row.changeTo.cloudFlavorCode : scope.row.cloudFlavorCode)
                                                }}
                                            </template>
                                            </label
                                        >
                                    </div>
                                <template>
                                    <div style="margin-bottom: 6px">
                                        <label>规格：</label>
                                        <template v-if="scope.row.flavorType == 1">
                                            <!-- {{cloudFlavorCodess(scope.row.changeTo?scope.row.changeTo.cloudFlavorCode : scope.row.cloudFlavorCode)}} -->
                                            {{ scope.row.changeTo.cpuNumber }}核vCPU；{{ scope.row.changeTo.memorySize }}G内存；
                                        </template>
                                        <template v-if="scope.row.flavorType == 2">
                                            {{wlfwqListss(scope.row.changeTo?scope.row.changeTo.cloudFlavorCode : scope.row.cloudFlavorCode)}}
                                        </template>
                                    </div>
                                </template>
                                <div
                                    style="margin-bottom: 6px"
                                    v-if="scope.row.changeTo.flavorType == 1 && scope.row.changeTo.osDisk"
                                >
                                    <label>系统盘：</label
                                    >{{
                                        scope.row.changeTo.osDisk.diskServerName
                                    }}，{{ scope.row.changeTo.osDisk.dataDiskSize }}GB
                                </div>
                                <div
                                    style="margin-bottom: 6px"
                                    v-if="scope.row.changeTo.flavorType == 1 || scope.row.changeTo.flavorType == 2"
                                >
                                    <label>操作系统：</label
                                    >{{ scope.row.changeTo.osName }}
                                </div>
                                <div style="margin-bottom: 6px" v-if="scope.row.changeTo.disks">
                                    <label>
                                        数据盘(共<span style="color: #e83112">{{
                                            scope.row.changeTo.disks.length
                                        }}</span
                                        >块){{
                                            scope.row.changeTo.disks.length ? ":" : ""
                                        }}</label
                                    >
                                </div>
                                <div
                                    v-if="scope.row.changeTo.disks"
                                    style="margin: 0 0 6px 16px"
                                    v-for="(item, index) in scope.row.changeTo.disks"
                                    :key="index"
                                >
                                    <span>{{ item.diskServerName }}</span
                                    >，{{ item.dataDiskSize }}GB
                                </div>
                            </div>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="wrap">
                <div class="wrap_title">
                    <div>数据库</div>
                </div>
                <el-table v-if="form.databases" :data="form.databases"  style="width: 100%;margin-top: 13px;">
                        <el-table-column label="版本">
                            <template slot-scope="scope">
                                <span>{{ scope.row.serverName }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="资源详情">
                            <template slot-scope="scope">
                                <div
                                if="scope.row.serverCode"
                                placement="top-start"
                                width="300"
                                trigger="hover">
                                    <div style="margin-bottom: 6px;">
                                        <label>类型：</label>
                                        <!-- {{scope.row.serverCode_label}} -->
                                        {{scope.row.serverName}}
                                    </div>
                                    <!-- <div style="margin-bottom: 6px;">
                                        <label>版本：</label>{{scope.row.databaseVersion}}
                                    </div> -->
                                    <div style="margin-bottom: 6px;">
                                        <label>位数：</label>{{scope.row.systemDigits}}
                                    </div>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="priceFlag"  width="600">
                            <template slot="header" slot-scope="scope">
                                <div style="text-align: center;">费用</div>
                                <div class="tab_wrap" >
                                    <div>名称</div>
                                    <div>单价</div>
                                    <div>用量</div>
                                    <div>总价（天）</div>
                                </div>
                            </template>
                            <template slot-scope="scope">
                                <div class="tab_wrap" v-for="(item,index) in scope.row.meterageList||[scope.row.meterage]" :key="index">
                                <div>{{item.resourceName}}</div>
                                <div>{{item.useCount}}{{item.useCountUnit}}</div>
                                <div> {{item.resourcePrice}}{{item.resourcePriceUnit}}</div>
                                <div> ¥{{item.resourcePriceTotalStr}}</div>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="变更后">
                        <template slot-scope="scope">
                            <!-- <div v-show="(form.databases[scope.$index].insStatus?form.databases[scope.$index].insStatus:form.databases[scope.$index].changeTo.insStatus)=='ADD'">未变更</div> -->
                            <div v-show="!scope.row.changeTo || !scope.row.changeTo.insStatus">未变更</div>
                            <div v-show="(form.databases[scope.$index].insStatus?form.databases[scope.$index].insStatus:form.databases[scope.$index].changeTo.insStatus)=='REMOVE'">已删除</div>
                            <div v-show="(form.databases[scope.$index].insStatus?form.databases[scope.$index].insStatus:form.databases[scope.$index].changeTo.insStatus)=='UPDATE'">
                                <div
                                    placement="top-start"
                                    width="300"
                                    trigger="hover"
                                >
                                    <div style="margin-bottom: 6px">
                                        <label>类型：</label
                                        >
                                        <!-- {{ returnserverCode_label(scope.row.changeTo) }}  -->
                                        {{scope.row.changeTo.serverName}}
                                    </div>
                                    <!-- <div style="margin-bottom: 6px">
                                        <label>版本：</label
                                        >{{ scope.row.changeTo.databaseVersion }}
                                    </div> -->
                                    <div style="margin-bottom: 6px">
                                        <label>位数：</label
                                        >{{ scope.row.changeTo.systemDigits }}
                                    </div>
                                </div>
                                </div>
                            </template>
                        </el-table-column>
                </el-table>
            </div>
            <div class="wrap">
                <div class="wrap_title">
                    <div>存储产品</div>
                </div>
                <el-table v-if="form.storeProducts" :data="form.storeProducts"  style="width: 100%;margin-top: 13px;">
                        <el-table-column label="磁盘类型">
                            <template slot-scope="scope">
                                {{ scope.row.diskServerName }}
                            </template>
                        </el-table-column>
                        <el-table-column label="磁盘用量">
                            <template v-if='scope.row.dataDiskSize' slot-scope="scope">
                                <span> {{ scope.row.dataDiskSize }}GB </span>
                            </template>
                        </el-table-column>
                        <el-table-column label="资源详情">
                        <template slot-scope="scope">
                            <div
                            placement="top-start"
                            width="300"
                            trigger="hover">
                                <div style="margin-bottom: 6px;">
                                    <label>存储类型：</label>{{scope.row.productCode}}
                                </div>
                                <div style="margin-bottom: 6px;">
                                    <label>服务类型：</label>{{scope.row.diskCode}}
                                </div>
                                <div style="margin-bottom: 6px;">
                                    <label>磁盘：</label>{{scope.row.diskServerName}}，{{scope.row.dataDiskSize}}GB
                                </div>
                                <div style="margin-bottom: 6px;">
                                    <label>服务器：</label>
                                    <div v-for="item in  scope.row.hostIds"> {{gethostName(item)}}</div>
                                </div>
                            </div>
                        </template>
                        </el-table-column>
                        <el-table-column v-if="priceFlag"  width="600">
                            <template slot="header" slot-scope="scope">
                                <div style="text-align: center;">费用</div>
                                <div class="tab_wrap" >
                                    <div>名称</div>
                                    <div>单价</div>
                                    <div>用量</div>
                                    <div>总价（天）</div>
                                </div>
                            </template>
                            <template slot-scope="scope">
                                <div class="tab_wrap" v-for="(item,index) in scope.row.meterageList||[scope.row.meterage]" :key="index">
                                <div>{{item.resourceName}}</div>
                                <div>{{item.useCount}}{{item.useCountUnit}}</div>
                                <div> {{item.resourcePrice}}{{item.resourcePriceUnit}}</div>
                                <div> ¥{{item.resourcePriceTotalStr}}</div>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="变更后">
                            <template slot-scope="scope">
                                <div v-show="!scope.row.changeTo || !scope.row.changeTo.insStatus">未变更</div>
                                <!-- <div v-show="(form.storeProducts[scope.$index].insStatus?form.storeProducts[scope.$index].insStatus:form.storeProducts[scope.$index].changeTo.insStatus)=='ADD'">未变更</div> -->
                                <div v-show="(form.storeProducts[scope.$index].insStatus?form.storeProducts[scope.$index].insStatus:form.storeProducts[scope.$index].changeTo.insStatus)=='REMOVE'">已删除</div>
                                <div v-show="(form.storeProducts[scope.$index].insStatus?form.storeProducts[scope.$index].insStatus:form.storeProducts[scope.$index].changeTo.insStatus)=='UPDATE'">
                                    <div
                                        placement="top-start"
                                        width="300"
                                        trigger="hover"
                                    >
                                        <div style="margin-bottom: 6px">
                                            <label>存储类型：</label
                                            >{{ scope.row.changeTo.productCode }}
                                        </div>
                                        <div style="margin-bottom: 6px">
                                            <label>服务类型：</label
                                            >{{ scope.row.changeTo.diskCode }}
                                        </div>
                                        <div style="margin-bottom: 6px;">
                                            <label>磁盘：</label>{{scope.row.changeTo.diskServerName}}，{{scope.row.changeTo.dataDiskSize}}GB
                                        </div>
                                        <div style="margin-bottom: 6px;">
                                            <label>服务器：</label>
                                            <div v-for="item in  scope.row.changeTo.hostIds"> {{gethostName(item)}}</div>
                                        </div>
                                    </div>
                                </div>
                            </template>
                        </el-table-column>
                </el-table>
            </div>
            <div  v-if="priceFlag"  style="margin-top: 10px;text-align: right;color: rgb(167,167,167);">
              预估费用：<span style="color: rgb(255,173,77);font-size: 24px;">¥{{parseInt(form.dailyPriceTotal)}}</span>/天
              <span style="margin-left: 20px;color: rgb(255,173,77);font-size: 24px;">¥{{parseInt(form.yearPriceTotal)}}</span>/年
            </div>
            <!-- <div class="title" style="margin-top: 30px;">安全产品</div> -->
            <!-- <div class="wrap1">
                <div style="width: 100%;"><span v-for="(item,index) in form.safeProducts" style="margin-left: 20px;" :key="index">{{item.productName}}</span></div>
            </div> -->
            <div class="wrap">
            <div class="wrap_title">
                <div>安全产品</div>
            </div>
            <div style="padding: 20px 20px; width: 100%">
                <el-table
                    :data="form.safeProductsList"
                    style="width: 100%; margin-top: 13px"
                >
                    <el-table-column label="产品名称">
                        <template slot-scope="scope">
                            {{ scope.row.name}}
                        </template>
                    </el-table-column>
                    <el-table-column label="数量">
                        <template slot-scope="scope">
                               {{ scope.row.ysnum}}
                            </template>
                    </el-table-column>
                     <el-table-column label="变更后数量">
                        <template slot-scope="scope">
                               {{ scope.row.num}}
                            </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
            <div v-if="otherFlag" class="title" style="margin-top: 30px;">其他</div>
            <div v-if="otherFlag" class="wrap2" style="padding-top: 1px;">
                <div style="display: flex;"><span style="font-weight: bold;margin-right: 10px;">说明:</span>{{form.remark}}</div>
               <div style="font-weight: bold;">文件:</div>
               <div style="display: flex;flex-wrap: wrap;">
                  <el-table
                    :data="form.files"
                    style="margin-left:20px;width: 50vw">
                        <el-table-column
                            label="文件名称"
                            >
                            <template slot-scope="scope">
                                {{scope.row.fileName}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            label="文件类型"
                            >
                            <template slot-scope="scope">
                                {{scope.row.fileExt}}
                            </template>
                        </el-table-column>
                        <el-table-column
                                label="操作"
                                width="100"
                                class-name="small-padding fixed-width"
                            >
                                <template slot-scope="scope">
                                    <el-button
                                        size="mini"
                                        type="text"
                                        icon="el-icon-view"
                                        @click="previewFile(scope.row)"
                                        >预览
                                    </el-button>
                                    <el-button
                                        size="mini"
                                        type="text"
                                        icon="el-icon-delete"
                                        @click="DeleteFile(scope.row.id)"
                                        >删除
                                    </el-button>
                                </template>
                            </el-table-column>
                    </el-table>
               </div>
            </div>
            <el-dialog :visible.sync="dialogVisible">
              <div style="max-height: 90vh;overflow-y: scroll;">
                <img width="100%" :src="dialogImageUrl" alt="">
              </div>
            </el-dialog>
        </div>
</template>

<script>
import {
    getResourcesChange,
} from "@/api/resources/change";
import { getDicts } from "@/api/system/dict/data";
import { treeselect } from "@/api/system/dept";
import {
    DelectUploadFile
  } from "@/api/cloud/cloud";
import {
    listByCode,
    classByCode,
    serviceByClazz,
} from "@/api/resources/apply";
export default {
    name: "detailindex",
    components: {},
    data() {
        return {
            form: null,
            otherFlag : true,
            priceFlag : false,
            // configure:JSON.parse(sessionStorage.getItem('configure')),
            //配置
            configure: {
                dept:[],
                available_domain: [], //可用域
                cloud_service_provider: [], //服务商
                storage_type: [], //系统盘类型
                codeList: [], //云服务器规格列表
                czxtList: [], //操作系统列表
                ccList: [], //数据盘类型
                fwcpList: [], //服务型磁盘类型
                wlfwqList: [], //高性能服务器资源类型
                sjkList: [], //数据库类型
                yyaqList: [], //安全产品
                CpuFrameworkList:[],//CPU架构
            },
            base_url:process.env.VUE_APP_BASE_API,
            dialogImageUrl: '',
            dialogVisible: false,
            cloud_up_areaList:[],
            loading:null,
        };
    },
    created(){
      this.loading = this.$loading({
                lock: true,
                text: '加载中...',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
              });
        // this.getDataOfAdd()
        getDicts("cloud_up_area").then((response) => {
            this.cloud_up_areaList = response.data;
        });
    },
    mounted(){
        getResourcesChange({id:this.$route.params.id,forUpdate:true}).then((res) => {
            this.getDataOfAdd(res.data)
        });
    },
    methods: {
      gethostName(id){
        let name =''
        this.form.hosts.some(item=>{
          if(item.id==id){
            name=item.hostName
            return true
          }
        })
        return name
      },
        // 翻译高性能规格
        cloudFlavorCodeDesc(data){
            var Name = ''
            this.configure.wlfwqList.forEach(item=>{
                if(item.code == data){
                    Name = item.remark
                }
            })
            return Name
        },
        getDataOfAdd(data){
            let detail = data;
            //可用域
            getDicts("available_domain").then((response) => {
                this.configure.available_domain = response.data;
            });
            //服务商
            getDicts("cloud_service_provider").then((response) => {
                this.configure.cloud_service_provider = response.data;
            });
            //盘类型
            serviceByClazz({ code: "cc",supplier:data.cloudUp.supplierCode }).then((response) => {
                response.data.forEach((item) => {
                    if (
                        ["FCcc(tykcc)2", "FCcc_ssd", "spycc2"].indexOf(
                            item.code
                        ) < 0
                    ) {
                        this.configure.storage_type.push(item);
                    }
                    if (["spycc2"].indexOf(item.code) < 0) {
                        this.configure.ccList.push(item);
                    }
                    if (
                        ["fbscc_wjcc2", "FCcc(tykcc)2", "FCcc_ssd"].indexOf(
                            item.code
                        ) < 0
                    ) {
                        this.configure.fwcpList.push(item);
                    }
                });
            });
            //操作系统
            classByCode({ code: "xc_os" }).then((response) => {
                console.log(response.data,999)
                this.configure.czxtList = response.data;
            });
            // //云服务器规格列表
            // listByCode("spec_ecs").then((response) => {
            //     this.configure.codeList = response.data;
            // });
            //高性能服务器资源类型列表
            serviceByClazz({ code: "wlfwq",supplier:data.cloudUp.supplierCode }).then((response) => {
                this.configure.wlfwqList = response.data;
            });
            //数据库类型列表
            serviceByClazz({ code: "sjk",supplier:data.cloudUp.supplierCode }).then((response) => {
                this.configure.sjkList = response.data;
            });
            //安全产品列表
            serviceByClazz({ code: "yyaq",supplier:data.cloudUp.supplierCode }).then((response) => {
                this.configure.yyaqList = response.data;
            });
            setTimeout(() => {
                detail.storeProducts.forEach((data) => {

                    this.configure[
                        data.productCode == "共享型" ? "ccList" : "fwcpList"
                    ].some((it) => {
                        if (it.code == data.diskServerCode) {
                            data.diskServerCode_label = it.serviceName;
                            return true;
                        }
                    });
                    data.hostInstanceNames = [];
                    data.hostIds=[]
                    if (data.hosts) {
                        data.hosts.forEach((item) => {
                            data.hostInstanceNames.push(item.instanceName);
                            data.hostIds.push(item.id);
                        });
                    }
                });
                detail.databases.forEach((data) => {
                    this.configure.sjkList.some((it) => {
                        if (it.code == data.serverCode) {
                            data.serverCode_label = it.serviceName;
                            return true;
                        }
                    });
                });
                detail.hosts.forEach((data) => {
                    data.hostName = data.instanceName;
                    //可用域
                    this.configure.available_domain.some((item) => {
                        if (item.dictValue == data.availableDomain) {
                            data.availableDomain_label = item.dictLabel;
                            return true;
                        }
                    });
                    //系统盘类型
                    if (data.osDisk) {
                        this.configure.storage_type.some((item) => {
                            if (item.code == data.osDisk.diskServerCode) {
                                data.osDisk.diskServerCode_label = item.serviceName;
                                return true;
                            }
                        });
                    }
                    //数据盘类型
                    if (data.disks) {
                        data.disks.forEach((item) => {
                            this.configure.ccList.some((it) => {
                                if (it.code == item.diskServerCode) {
                                    item.diskServerCode_label = it.serviceName;
                                    return true;
                                }
                            });
                        });
                    } else {
                        data.disks = [];
                    }
                    if (data.flavorType == 2) {
                        this.configure.wlfwqList.some((item) => {
                            if (item.code == data.cloudFlavorCode) {
                                data.cloudFlavorCode_label = item.serviceName;
                                data.cloudFlavorCode_desc = item.remark;
                                return true;
                            }
                        });
                    }
                });
                detail.safeProductsList=[];
                   let     productNames=[];
                detail.safeProducts.forEach(item=>{
                  if(productNames.indexOf(item.productName)<0){
                    productNames.push(item.productName)
                    let num=0
                    if(item.changeTo&&item.changeTo.insStatus!='REMOVE'){
                      num=1
                    }
                    detail.safeProductsList.push({name:item.productName,num,ysnum:1})
                  }else{
                    if(item.changeTo&&item.changeTo.insStatus!='REMOVE'){
                      detail.safeProductsList[productNames.indexOf(item.productName)].num++
                    }
                    detail.safeProductsList[productNames.indexOf(item.productName)].ysnum++
                  }
                })
                this.form = detail;
                this.loading.close()
            }, 0);
        },
        translatecloudUpArea(data){
            var Name = ''
            this.cloud_up_areaList.forEach(item=>{
                if(item.dictValue == data){
                    Name = item.dictLabel
                }
            })
            return Name
        },
        // 等保可用域翻译
        availableDomains(id){
            let availableDomainName
            this.configure.available_domain.forEach(item=>{
                if(id == item.dictValue){
                    availableDomainName = item.dictLabel
                }
            })
            return availableDomainName
        },
        cloudFlavorCodes(id){
            let cloudFlavorCodeName
            this.configure.codeList.forEach(item=>{
                if(item.specCode == id){
                    cloudFlavorCodeName = item.specName
                }
            })
            return cloudFlavorCodeName
        },
        cloudFlavorCodess(id){
            let cloudFlavorCodeName
            this.configure.codeList.forEach(item=>{
                if(item.specCode == id){
                    cloudFlavorCodeName = item.desc
                }
            })
            return cloudFlavorCodeName
        },
        wlfwqLists(id){
            let cloudFlavorCodeName
            this.configure.wlfwqList.forEach(item=>{
                if(item.code == id){
                    cloudFlavorCodeName = item.serviceName
                }
            })
            return cloudFlavorCodeName
        },
        wlfwqListss(id){
            let cloudFlavorCodeName
            this.configure.wlfwqList.forEach(item=>{
                if(item.code == id){
                    cloudFlavorCodeName = item.remark
                }
            })
            return cloudFlavorCodeName
        },
        previewFile(item){
            if(item.fileExt == 'jpeg' ||
                item.fileExt == 'jpg' ||
                item.fileExt == 'png' ||
                item.fileExt == 'gif' ||
                item.fileExt == 'pdf'){
                        this.dialogImageUrl = this.base_url + item.filePath;
                        this.dialogVisible = true;
                }else{
                    this.$message.error(`仅限后缀名为 gif、jpeg、jpg、png 可预览`);
                }
        },
        DeleteFile(id){
            this.$confirm("是否删除该文件?", "警告", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                })
                .then(() => {
                    DelectUploadFile(id).then(res => {
                    if (res.code == 200) {
                        this.form.files = this.form.files.filter(item => {
                        if (item.id == id) {

                        } else {
                            return item
                        }
                        })
                        this.$message({
                        message: '删除成功',
                        type: 'success'
                        });
                    }
                    })
            })
        },
    },
};
</script>

<style scoped lang="less">
.dialog {
    padding-right: 20px;
    font-size: 12px;
    .title {
        text-align: left;
        margin-bottom: 20px;
        font-size: 16px;
        font-weight: bold;
        padding-left: 4px;
        border-left: 4px solid #38b3aa;
    }
    .wrap {
        display: flex;
        background: #faf9ff;
        margin-top: 20px;
        border-radius: 10px;

        .wrap_title {
            padding: 0 10px;
            background: #f4f4f4;
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px;

            div {
                height: 100%;
                width: 14px;
                font-weight: bold;
                display: flex;
                flex-direction: column;
                justify-content: center;
            }
        }

        .wrap_item {
            display: flex;
            margin-top: 20px;

            div:first-child {
                width: 90px;
                font-weight: bold;
            }

            i {
                line-height: 28px;
                margin-right: 10px;
                font-size: 20px;
                color: #e83112;
            }
        }
    }
    .wrap1 {
        padding: 0 20px 20px 0px;
        background: #faf9ff;
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 30px;
        // justify-content: space-between;
        border-radius: 10px;
        div {
            margin-top: 20px;
            padding-bottom: 10px;
            padding-left: 20px;
            width: calc(33.33% - 20px);
            min-width: 340px;
            display: flex;
            border-bottom: 1px solid rgba(192,196,204,0.5);
            div {
                width: 120px;
                min-width: 100px;
                font-weight: bold;
                margin: 0;
                display: flex;
                padding-right: 10px;
                justify-content: end;
                color: #606266;
                border-bottom: none;
            }
        }
    }
    .wrap2 {
        padding: 0 20px 20px 20px;
        background: #faf9ff;
        margin-bottom: 30px;
        justify-content: space-between;
        border-radius: 10px;
        div {
            margin-top: 20px;
        }
    }
    .wrap3 {
        padding: 20px;
        background: #faf9ff;
        margin-bottom: 30px;
        justify-content: space-between;
        border-radius: 10px;
    }
    .tab_wrap {
        display: flex;
        justify-content: space-between;
        div {
            width: 25%;
            padding: 10px 0;
        }
        div:first-child {
            font-weight: bold;
        }
    }
}
</style>
